<?php
/**
 * @Author: anchen
 * @Date:   2017-04-23 20:52:08
 * @Last Modified by:   anchen
 * @Last Modified time: 2017-04-23 20:59:33
 */
/**
 * 随机生成字符串
 * @param  int $length
 * @return string
 */
function getRandChar($length = 10){
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $randomString = '';
    for($i=0;$i<$length;$i++){
        $randomString .= $characters[rand(0,strlen($characters) -1)];
    }
    return $randomString;
}

echo getRandChar(30);